//
//  XQCustomPriceView.m
//  JoinPeso
//
//  Created by 小琦 on 2024/11/21.
//

#import "XQCustomPriceView.h"

@interface XQCustomPriceView()
@property (nonatomic,strong) UILabel *dollorLb;
@property (nonatomic,strong) UILabel *priceLb;
@end

@implementation XQCustomPriceView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self makeUI];
        [self makeConstraints];
    }
    return self;
}

- (void)makeUI {
    [self addSubview:self.dollorLb];
    [self addSubview:self.priceLb];
}

- (void)makeConstraints {
    [self.priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.bottom.equalTo(@0);
        make.height.mas_equalTo(32);
    }];
    [self.dollorLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.priceLb);
        make.left.equalTo(@0);
        make.right.equalTo(self.priceLb.mas_left).offset(-2);
    }];
}

#pragma mark - setter

- (void)setPrice:(NSString *)price {
    self.priceLb.text = price;
}

- (void)setDollor:(NSString *)dollor {
    self.dollorLb.text = dollor;
}

#pragma mark - lazy

- (UILabel *)dollorLb {
    if (!_dollorLb) {
        _dollorLb = [[UILabel alloc] init];
        _dollorLb.text = @"₱";
        _dollorLb.textColor = kBlackTextColor;
        _dollorLb.font = [UIFont systemFontOfSize:16];
        [_dollorLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
        [_dollorLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    }
    return  _dollorLb;
}

- (UILabel *)priceLb {
    if (!_priceLb) {
        _priceLb = [[UILabel alloc] init];
        _priceLb.textColor = kBlackTextColor;
        _priceLb.font = [UIFont boldSystemFontOfSize:28];
        _priceLb.adjustsFontSizeToFitWidth = YES;
    }
    return  _priceLb;
}

@end
